@echo off
setlocal

set "filename=%1"
set "dir=%2"
set "output=%3"
set "dosbox=%4"

copy %dir%\%filename%.asm %CD%\%filename%.asm>NUL

bin\ML.EXE /nologo /c /Fl /Zi %filename%.asm || goto terminate

bin\LINK16.exe /nologo /CO %filename%.obj io16.lib; || goto terminate

del %filename%.asm
copy %filename%.exe %dosbox%\dir\%filename%.exe
if not exist %output% mkdir %output%
move %filename%.* %output%

echo opening %filename%.exe in DOSBox...
%dosbox%\dosbox.exe -c "mount c %dosbox%\dir" -c "c:" -c "%filename%.exe"
:terminate
endlocal
@echo on
